import request from '@/request/index.js';
const apiType = 'ToC/' ;
import store from "@/store/index.js" ;
import { phoneCode } from '@/utils/util.js'
import platform from '@/core/platform.js'
export default {
	//获取sessionKey、openid
	getJsCode2Session(code) {
		return request.post('youzy.tms.v1.miniprogram.wechat.auth.code2session.get', {
			code
		})
	},
	//解析手机号
	decryptMobile(data) {
		return request.post('youzy.tms.v1.miniprogram.mobile.decrypt.get', data)
	},
	getUserBrief() {
		const data = {
		  isFillAreaName: true,
		  isFillPermission: true,
		  isEncryptMobile: false,
		  isMasking: false
		}
		return request.post('youzy.tms.v1.users.user.briefinfo.get', data).then(async res => {
			const result = res.result ;
			if (res.isSuccess&&result&&result.id){
				result.encryptMobilePhone = phoneCode(result.mobilePhone)
				store.commit('SET_USER_INFO', result)
				if(result.ageStage){
					store.commit('SET_USER_INFO_STORAGE', {
						ageStage: result.ageStage,
						gender: result.gender
					})		
				}
			} else {
				store.dispatch('Logout')
			}
			return res
		})
	},


}
